package de.tudarmstadt.fgbs.cafe.ui;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.naming.CommunicationException;

import de.tudarmstadt.fgbs.cafe.exception.FlawedConfigurationException;
import de.tudarmstadt.fgbs.cafe.plugin.management.PluginManagerInterface;
import de.tudarmstadt.fgbs.cafe.structure.Bahnhof;
import de.tudarmstadt.fgbs.cafe.structure.Fahrplan;
import de.tudarmstadt.fgbs.cafe.structure.PluginStruct;
import de.tudarmstadt.fgbs.cafe.structure.Zuglauf;

public interface UICoreInterface {

    /**
     * Checks the user's authentication via password.
     * 
     * @param username
     *            The name of the user.
     * @param password
     *            The password of the user.
     * @return <code>true</code> if the user is authorized to use the system,
     *         otherwise <code>false</code>
     * @throws FlawedConfigurationException
     *             If the configuration is faulty and no instance of the
     *             required class can be created.
     * @throws CommunicationException
     *             If a remote service is used and an error occurred while
     *             communicate with this server.
     * @throws IOException
     *             If a required configuration can not be found.
     */
    public boolean login(String username, String password)
	    throws FlawedConfigurationException, CommunicationException,
	    IOException;

    /**
     * Gets all available plugins.
     * 
     * @return A {@link List} of plugins which are represented by a
     *         {@link PluginStruct}.
     * @throws FlawedConfigurationException
     *             If the configuration is faulty and no instance of a class
     *             implementing the {@link PluginManagerInterface} can be
     *             created.
     */
    public List<PluginStruct> getPlugins() throws FlawedConfigurationException;

    public int createFPL(String name) throws FlawedConfigurationException;

    public boolean addZL(int fplID, Zuglauf zl)
	    throws FlawedConfigurationException;

    public Fahrplan mergeFPLs(String[] names)
	    throws FlawedConfigurationException;

    public Fahrplan importFPL(String location)
	    throws FlawedConfigurationException;

    public boolean exportFPL(int fplID, String name, String location)
	    throws FlawedConfigurationException;

    public Map<Integer, Fahrplan> retrieveAllFPL()
	    throws FlawedConfigurationException;

    public Fahrplan retrieveFPL(int id) throws FlawedConfigurationException;

    public Fahrplan retrieveFPL(String name)
	    throws FlawedConfigurationException;

    public Zuglauf retrieveZL(int fplID, String zlNr)
	    throws FlawedConfigurationException;

    public Map<String, Bahnhof> retrieveBahnhofMap()
	    throws FlawedConfigurationException;

    public int getFPLID(Fahrplan fpl) throws FlawedConfigurationException;

    public boolean exportFPL(Fahrplan fpl, String name, String absolutePath)
	    throws FlawedConfigurationException;

    public void removeFPL(String name) throws FlawedConfigurationException;

    public void saveCurrentWork(Fahrplan fpl)
	    throws FlawedConfigurationException;

    public Fahrplan restorePreviousWork(int undoSteps)
	    throws FlawedConfigurationException;

}
